from datetime import timedelta

from jms.ods import jms_ods__yl_oms_oms_waybill
from utils.operators.cluster_for_spark_sql_operator import SparkSqlOperator

jms_data_check__oms_waybill_dt = SparkSqlOperator(
    task_id='jms_data_check__oms_waybill_dt',
    task_concurrency=1,
    pool_slots=7,
    master='yarn',
    name='jms_data_check__oms_waybill_dt_{{ execution_date | date_add(1) | cst_ds }}',
    sql='jms/datacheck/ml/oms_waybill/execute.hql',
    email=['yushuo@jtexpress.com','yl_bigdata@yl-scm.com'],
    executor_cores=2 , 
    executor_memory='1G' , 
    num_executors=2 , 
    conf={'spark.dynamicAllocation.enabled'                  : 'true',  # 动态资源开启
          'spark.shuffle.service.enabled'                    : 'true',  # 动态资源 Shuffle 服务开启
        'spark.dynamicAllocation.maxExecutors'             : 2 , 
          'spark.dynamicAllocation.cachedExecutorIdleTimeout': 60,  # 动态资源自动释放闲置 Executor 的超时时间(s)
          'spark.sql.sources.partitionOverwriteMode'         : 'dynamic',  # 允许删改已存在的分区
        'spark.executor.memoryOverhead'             : '1G' , 
          'spark.sql.shuffle.partitions'                     : 600,
          },
    hiveconf={'hive.exec.dynamic.partition'             : 'true',  # 动态分区
              'hive.exec.dynamic.partition.mode'        : 'nonstrict',
              'hive.exec.max.dynamic.partitions'        : 20,  # 每天生成 20 个分区
              'hive.exec.max.dynamic.partitions.pernode': 20,  # 每天生成 20 个分区
              },
    yarn_queue='pro',
    execution_timeout=timedelta(hours=5),
)

jms_data_check__oms_waybill_dt << jms_ods__yl_oms_oms_waybill